﻿

namespace Huirui.Cavan.Presentation.Controller.HomeModule
{
    using Huirui.Cavan.Application.MainBoundedContext.SystemModule;
    using Huirui.Cavan.Domain.MainBoundedContext.SearchModule;
    using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
    using Huirui.Cavan.Presentation.Seedwork;
    using Huirui.Cavan.Presentation.ViewModel.SystemModule;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;


    public class HomeController : EntityController<UserAccount, UserAccountSearch, IUserAccountViewModel, IUserAccountAppService>, IHomeController
    {
        public override string ControllerName
        {
            get { return "home"; }
        }

        public override bool UseDenied
        {
            get { return false; }
        }

        public HomeController()
        {
            this.Model = ModelFactory.CreateModel<IUserAccountViewModel>();
        }

        public ActionResult Index()
        {
            //return View("~/Views/Home/index.cshtml");
            return View("~/Views/Home/login.cshtml");
        }

        [ActionName(ActionConst.LOGIN)]
        [HttpPost]
        public ActionResult Login(UserAccountViewModel user)
        {
            user.Item.IsLocked = false;
            if (user != null && user.Item.Name == "huirui" && user.Item.Password == "goodluck")
            {
                return View("~/Views/Home/index.cshtml");
            }
            else
            {
                user.Item.IsLocked = true;
                return View("~/Views/Home/login.cshtml",user);
            }
        }

        [ActionName("homeicon")]
        public ActionResult GetHomeIcon()
        {
            return PartialView("~/Views/Home/partial/homeIcon.cshtml");
        }
    }
}
